package com.example.demo.controller;

import com.example.demo.entity.ApiResponse;
import com.example.demo.entity.StatusCodeMenu;
import com.example.demo.entity.StatusMessageMenu;
import com.example.demo.repository.RoleMapper;
import com.example.demo.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    RoleService roleService;

    @GetMapping(value = "/getRole")
    public ApiResponse getRole(@RequestParam("username")String username){
        Integer code = StatusCodeMenu.SUCCESS;
        String message = StatusMessageMenu.SUCCESS;
        Integer role = roleService.getRoleByUsername(username);
        return new ApiResponse(code, message, role);
    }
}
